Python: Add music player example#158
Conversation
DanielRosenwasser
left a comment
There was a problem hiding this comment.
Overall looks promising! I didn't see much else that jumped out at me. I do want to give it a try locally, and I think @steveluc might want to look things over.
|
|
||
|
|
||
| async def handle_call(action: PlayerAction, context: ClientContext): | ||
| match action["actionName"]: |
There was a problem hiding this comment.
Something we could do is use a class with a bunch of methods with hasattr. I've suggested we could do something similar with a plain object in the TypeScript implementation too.
For now it is probably fine as-is. I wouldn't rewrite everything unless you think you can do it quickly.
There was a problem hiding this comment.
I've been looking for a way to verify type signatures at runtime. As far as I can tell, the TypedDicts are just dicts at runtime so we cannot "assert x is T" or "cast x as T" to ensure the right properties are present, Let me know if you find a way to do this.
steveluc
left a comment
There was a problem hiding this comment.
Thanks for getting this one ported! It looks good. I'd love to try running it locally. Let's merge and try it out.
This change adds a music player example to the python typechat implementation. Unlike the typescript edition, this example does not rely on JsonProgram. Instead, the music player schema is exposed as a set of actions (and their corresponding parameter types). The model selects a sequence of actions to run. These are passed to a handler function that executes them in order.
The code is organized as follows: